crPESelectPrinter
The crPESelectPrinter function specifies a printer other than the default printer as a print destination. You can use this function to enable the user to select a printer other than the default printer at print time. One way of doing this is to have your application call the common printer selection dialog box.
Declare Function crPESelectPrinter Lib "crwrap32.dll" (ByVal printJob As
Integer, ByVal driverName As String, ByVal printerName As String, ByVal
portName As String, crmode As crDEVMODE) As Integer
Parameters
printJob
| Specifies the handle to the print job for which you want to select a printer.
|
driverName*
| Specifies a pointer to a null-terminated string that contains the name of the printer driver for the selected printer.
|
printerName*
| Specifies a pointer to a null-terminated string that contains the printer name for the selected printer.
|
portName*
| Specifies a pointer to a null-terminated string that contains the port name for the port to which the selected printer is attached.
|
mode*
| Specifies the crDEVMODE structure.
|
*The PRINTDLG structure, returned by the Windows API PrintDlg function, contains handles to crDEVMODE and DEVNAMES structures. This information can be used to obtain driverName, printerName, portName, and mode values for crPESelectPrinter.
|
Return Value
TRUE (1) if the call is successful, FALSE (0) if the call fails.
Remarks
- Your code must parse the return from the dialog box selection and insert the returned driverName, printerName, and portName as parameters in the call.
- After selecting the printer with this call, you can direct the output to that printer (using the PEOutputToPrinter call) or to the print window (using the PEOutputToWindow call).
- This call will override a printer selection that you built into the report at design time via the Select Printer menu command.
- If you follow this call with the PEOutputToWindow call, the report appears in the Print Window formatted for the selected printer.
- To revert to the default printer, pass zeros (0) for each parameter.
- The driver name and printer name must exist on your machine.
- You can specify a different printer port than that assigned to the selected printer on your machine.
- For mode, use 0 for the default mode or create a crDEVMODE structure to customize (if your development tool supports such a structure.) For additional information on DEVMODE structures, see the documentation that comes with the Microsoft Windows Software Development Kit (SDK).